LanguageExt.Core

LanguageExt.Core DataTypes Compositions

Contents

struct Compositions <A> Source #

where A : Monoid<A>

A compositions list or composition tree is a list data type where the elements are monoids, and the 'mconcat' of any contiguous sublist can be computed in logarithmic time.

A common use case of this type is in a wiki, version control system, or collaborative editor, where each change or delta would be stored in a list, and it is sometimes necessary to compute the composed delta between any two versions.

This version of a composition list is strictly biased to right-associativity, in that we only support efficient consing to the front of the list. This also means that the 'take' operation can be inefficient.

The append operation append(a, b) performs O(a log (a + b)) element compositions, so you want the left-hand list a to be as small as possible.

Fields

field Seq<Node> Tree Source #

Properties

property Compositions<A> Empty Source #

Methods

method Compositions<A> Combine (Compositions<A> compy) Source #

method bool WellFormed <EqA> () Source #

where EqA : Eq<A>

Returns true if the given tree is appropriately right-biased.

method Compositions<A> Skip (int amount) Source #

Return the compositions list with the first k elements removed, in O(log k) time.

method Compositions<A> Take (int amount) Source #

Return the compositions list containing only the first k elements of the input. In the worst case, performs O(k log k) element compositions, in order to maintain the right-associative bias. If you wish to run composed on the result of take, use takeComposed for better performance.

method A TakeComposed (int amount) Source #

Returns the composition of the first k elements of the compositions list, doing only O(log k) compositions. Faster than simply using take and then composed separately.

method (Compositions<A> taken, Compositions<A> skipped) SplitAt (int i) Source #

A convenience alias for 'take' and 'skip'

method A Composed () Source #

Compose every element in the compositions list. Performs only O(log n) compositions.

method Compositions<A> Singleton (A value) Source #

Construct a compositions list containing just one element.

method int Count () Source #

Get the number of elements in the compositions list, in O(log n) time.

method Compositions<A> FromList (IEnumerable<A> ma) Source #

Convert a compositions list into a list of elements. The other direction is provided in the 'Data.Foldable.Foldable' instance.This will perform O(n log n) element compositions.

method bool Equals (Compositions<A> b) Source #

Equality operator

method bool Equals (object? obj) Source #

Equality operator

method int GetHashCode () Source #

Get hash code

Parameters

returns

method Seq<A> ToSeq () Source #

Convert to a sequence

method EnumerableM<A> AsEnumerable () Source #

Convert to an enumerable

method IEnumerator<A> GetEnumerator () Source #

Get enumerator

Operators

operator == (Compositions<A> a, Compositions<A> b) Source #

Equality operator

operator != (Compositions<A> a, Compositions<A> b) Source #

Equality operator

class Node Source #

Fields

field int Size Source #

field Option<(Node, Node)> Children Source #

field A Value Source #

Constructors

constructor Node (int size, Option<(Node, Node)> children, A value) Source #

class CompositionsExt Source #

Methods

method Compositions<A> Cons <A> (this A a, Compositions<A> ma) Source #

where A : Monoid<A>

class Compositions Source #

Methods

method bool wellFormed <EqA, A> (Compositions<A> ca) Source #

where EqA : Eq<A>
where A : Monoid<A>

Returns true if the given tree is appropriately right-biased.

method Compositions<A> skip <A> (int amount, Compositions<A> compositions) Source #

where A : Monoid<A>

Return the compositions list with the first k elements removed, in O(log k) time.

method Compositions<A> take <A> (int amount, Compositions<A> compositions) Source #

where A : Monoid<A>

Return the compositions list containing only the first k elements of the input. In the worst case, performs O(k log k) element compositions, in order to maintain the right-associative bias. If you wish to run composed on the result of take, use takeComposed for better performance.

method A takeComposed <A> (int amount, Compositions<A> compositions) Source #

where A : Monoid<A>

Returns the composition of the first k elements of the compositions list, doing only O(log k) compositions. Faster than simply using take and then composed separately.

method (Compositions<A> taken, Compositions<A> skipped) splitAt <A> (int i, Compositions<A> c) Source #

where A : Monoid<A>

A convenience alias for 'take' and 'drop'

method A composed <A> (Compositions<A> compositions) Source #

where A : Monoid<A>

Compose every element in the compositions list. Performs only O(log n) compositions.

method Compositions<A> singleton <A> (A value) Source #

where A : Monoid<A>

Construct a compositions list containing just one element.

method int count <A> (Compositions<A> compositions) Source #

where A : Monoid<A>

Get the number of elements in the compositions list, in O(log n) time.

method Compositions<A> cons <A> (A x, Compositions<A> xs) Source #

where A : Monoid<A>

Add a new element to the front of a compositions list. Performs O(log n) element compositions.

method Compositions<A> fromList <A> (IEnumerable<A> ma) Source #

where A : Monoid<A>

Convert a compositions list into a list of elements. The other direction is provided in the 'Data.Foldable.Foldable' instance.This will perform O(n log n) element compositions.

struct FoldCompositions <A> Source #

where A : Monoid<A>

Methods

method Func<Unit, int> Count (Compositions<A> fa) Source #

method Func<Unit, S> Fold <S> (Compositions<A> fa, S state, Func<S, A, S> f) Source #

method Func<Unit, S> FoldBack <S> (Compositions<A> fa, S state, Func<S, A, S> f) Source #